﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SwitchUserForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.CommForm.SwitchUserForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>切换用户</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" method="post">
    <div style="padding-left: 11px; padding-bottom: 5px;">
        <table class="form-table" style="table-layout: fixed; width: 100%; padding: 10px;
            padding-top: 10px;">
            <tr>
                <td style="width: 60px;">
                    <label for="username$text">
                        帐号：</label>
                </td>
                <td>
                    <input id="LoginCode" name="LoginCode" class="mini-textbox" required="true" style="width: 150px;" />
                </td>
            </tr>
            <tr>
                <td style="width: 60px;">
                    <label for="pwd$text">
                        密码：</label>
                </td>
                <td>
                    <input id="LoginPwd" name="LoginPwd" onvalidation="onPwdValidation" class="mini-password"
                        requirederrortext="密码不能为空" required="true" style="width: 150px;" onenter="onLoginClick" />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td style="padding-top: 5px;">
                    <a onclick="onLoginClick" class="mini-button" style="width: 60px;">登录</a> <a onclick="onResetClick"
                        class="mini-button" style="width: 60px;">重置</a>
                </td>
            </tr>
        </table>
    </div>
    </form>
    <script type="text/javascript">
        mini.parse();
        var form = new mini.Form("form1");
        function onResetClick() {
            form.clear();
        }
        function onPwdValidation(e) {
            if (e.isValid) {
                if (e.value.length < 3) {
                    e.errorText = "密码不能少于3个字符";
                    e.isValid = false;
                }
            }
        }
        function onLoginClick(e) {
            form.validate();
            if (form.isValid() == false) return;
            var o = form.getData();
            $.ajax({
                url: "../service/PublicHandler.ashx?action=Login&LoginCode=" + o.LoginCode + "&LoginPwd=" + o.LoginPwd,
                success: function (text) {
                    if (text == 0) {
                        mini.alert("您输入的帐号不存在，请重新输入！");
                        mini.get("LoginCode").setValue("");
                        mini.get("LoginPwd").setValue("");
                    }
                    else if (text == 1) {
                        mini.alert("帐号或密码已被锁定，请联系管理员！");
                        mini.get("LoginPwd").setValue("");
                    }
                    else if (text == 2) {
                        mini.alert("帐号或密码有误，请重新输入！");
                        mini.get("LoginPwd").setValue("");
                    }
                    else if (text == 3) {
                        mini.loading("登录成功，马上转到系统...", "登录成功");
                        setTimeout(function () {
                            top.location.href = "../index.aspx";
                        }, 1500);
                    }
                },
                error: function () {
                }
            });
        }
    </script>
</body>
</html>
